package com.lagou.servlet;

import com.lagou.server.HttpProtocolUtil;
import com.lagou.server.HttpServlet;
import com.lagou.server.Request;
import com.lagou.server.Response;

import java.io.IOException;

public class MyServlet extends HttpServlet {

    @Override
    public void doGet(Request request, Response response) throws IOException, InterruptedException {
//        Thread.sleep(100000);
        String content = "<h1>MyServlet doGet<h1>";
        /**
         * 响应头
         */
        response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length));
        /**
         * 响应体
         */
        response.output(content);
    }

    @Override
    public void doPost(Request request, Response response) throws IOException {
        String content = "<h1>MyServlet doPost<h1>";
        /**
         * 响应头
         */
        response.output(HttpProtocolUtil.getHttpHeader200(content.getBytes().length));
        /**
         * 响应体
         */
        response.output(content);
    }

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destroy() throws Exception {

    }

}
